<template>
     
    
         <div class="login">
               <img src="../assets/bb.png">
                <el-input v-model="username" placeholder="请输入账号" style="margin-top: 20px;"></el-input>
                <el-input v-model="userpaswoer" placeholder="请输入密码" style="margin-top: 20px;"></el-input>
                <div v-if="isError">
                    <p style="color: red;">用户名或者密码错误，请重新输入</p>
                </div>

                <el-button type="warning" v-on:click="dologin" style="width: 100%;margin-top: 20px;">马上登录</el-button>
                <xianyu></xianyu>
         </div>
          
     
      
</template>

<script>
    import thaer from '@/components/posin' 
    import xianyu from '@/components/qitadlu' 

     export default {
        name:'userlogin',
        components:{thaer,xianyu},

        data(){
            return{
                username:'',
                userpaswoer:'',
                isError:false
            }
        },
        methods:{
           dologin(){
                // console.log('this.username');
                // this.username=22222;
               this.ajax.get('../../static/json/uerr.json').then( res=>{
                for (var i = 0; i < res.data.length; i++) {
                    if(this.username == res.data[i].username && this.userpaswoer == res.data[i].password){
                        this.$store.commit('dologin',this.username);
                        console.log(this.$store.state.islogin);
                        this.$router.push({path:"/user/center"});
                    }else{
                       
                       this.isError=true;
                    }
                }
               })
           }
        }

     }

</script>

<style scoped>
    .login{
        margin-top: 30px;
        border: 1px solid #ccc;
        width: 500px;
        height: 700px;
        /*text-align: center;*/
        margin: 0 auto;
    }
</style>